﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tao.Platform.Windows;
using System.Windows.Forms;
using Clandestine;

namespace Slick
{
    public delegate void FormsDelegate();
    public class GlControlManager : IGlManager
    {
        public SimpleOpenGlControl Control;

        public string Name
        {
            get { return "Windows Forms GL Control Manager"; }
        }

        public GlControlManager(SimpleOpenGlControl control)
        {
            this.Control = control;
        }

        public void Initialise(int zoomOverride, int ScreenWidth, int ScreenHeight)
        {
            Control.InitializeContexts();
        }

        public void Deinitialise()
        {

        }

        public void OnRender()
        {
            //Control.SwapBuffers();
        }

        public void GetViewportSize(out int w, out int h)
        {
            int w1 = 0; // can't access w and h inside delegate
            int h1 = 0;

            w1 = Control.Width;
            h1 = Control.Height;

            w = w1;
            h = h1;
        }

        private int OnWindowClose()
        {
            //  lock (Graphics.RenderLockBlob)
            //      Program.Running = false;
            // return 1; // Don't close (yet)!
            return 0;
        }

        public void SetWindowTitle(string s)
        {
            //  Glfw.glfwSetWindowTitle(s);
        }
    }
}
